#include<stdio.h>
#include<time.h>
#include<unistd.h>
#include<stdlib.h>
#include"Progress.h"

int base = 10;         //随机数范围
double total = 2048.0; //假设需要下载的总容量为2048
double once = 0.1;     //一次最少能下载0.1

//模拟真实进度条下载行为，会有波动
void download()
{
    double current = 0.0;
    while(current < total)
    {
        int r = rand() % base + 1;  //随机数范围是[1,10]
        double speed = once * r;    //一次下载进度

        current += speed;
        if(current >= total) current = total;
        usleep(10000);
        Process(current,total); 
        //printf("%lf : %lf\r",current,total);
        //fflush(stdout);
    }
    printf("\r\n");
}


int main()
{
    srand(time(NULL));
    download();
    //Process();
    return 0;
}
